<?php
class Slog_Db_Table
{
	/**
	 * @var	Slog_Db_Driver
	 */
	static protected $_driver;
	
	protected $_name;
	
	public function __construct()
	{
		// convertimos CamelCase a nombre_tabla
		//$this->_name = strtolower(ltrim(preg_replace('/([A-Z]{1})/', '_$1', get_class($this)), '_'));
		$this->_name = Slog_String::camelCaseToVar( get_class($this) );
	}
	
	static public function setDriver(Slog_Db_Driver $db)
	{
		self::$_driver = $db;
	}
	/**
	 * Devuelve el driver de BD activo
	 *
	 * @return	Slog_Db_Driver
	 */
	static public function getDriver()
	{
		return self::$_driver;
	}
	
	public function getName()
	{
		return $this->_name;
	}
	
	public function insert($data)
	{
		
	}
	
	public function update($data, $where)
	{
		
	}
	
	public function delete($data, $where)
	{
		
	}
	
	public function __call($method, $params)
	{
		if (method_exists(self::$_driver, $method)) {
			return call_user_func_array(array(self::$_driver, $method), $params);
		}
		
		throw new Exception('Método no existe: ' . $method);
	}
}